<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class ENV - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-ENV-label-Interaction+with+the+Operating+System">Interaction with the Operating System</a>
    <li><a href="#class-ENV-label-Names+and+Values">Names and Values</a>
    <li><a href="#class-ENV-label-Valid+Names+and+Values">Valid Names and Values</a>
    <li><a href="#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>
    <li><a href="#class-ENV-label-About+Ordering">About Ordering</a>
    <li><a href="#class-ENV-label-About+the+Examples">About the Examples</a>
    <li><a href="#class-ENV-label-What-27s+Here">What’s Here</a>
    <li><a href="#class-ENV-label-Methods+for+Querying">Methods for Querying</a>
    <li><a href="#class-ENV-label-Methods+for+Assigning">Methods for Assigning</a>
    <li><a href="#class-ENV-label-Methods+for+Deleting">Methods for Deleting</a>
    <li><a href="#class-ENV-label-Methods+for+Iterating">Methods for Iterating</a>
    <li><a href="#class-ENV-label-Methods+for+Converting">Methods for Converting</a>
    <li><a href="#class-ENV-label-More+Methods">More Methods</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-5B-5D">::[]</a>
    <li ><a href="#method-c-5B-5D-3D">::[]=</a>
    <li ><a href="#method-c-assoc">::assoc</a>
    <li ><a href="#method-c-clear">::clear</a>
    <li ><a href="#method-c-clone">::clone</a>
    <li ><a href="#method-c-delete">::delete</a>
    <li ><a href="#method-c-delete_if">::delete_if</a>
    <li ><a href="#method-c-dup">::dup</a>
    <li ><a href="#method-c-each">::each</a>
    <li ><a href="#method-c-each_key">::each_key</a>
    <li ><a href="#method-c-each_pair">::each_pair</a>
    <li ><a href="#method-c-each_value">::each_value</a>
    <li ><a href="#method-c-empty-3F">::empty?</a>
    <li ><a href="#method-c-except">::except</a>
    <li ><a href="#method-c-fetch">::fetch</a>
    <li ><a href="#method-c-filter">::filter</a>
    <li ><a href="#method-c-filter-21">::filter!</a>
    <li ><a href="#method-c-freeze">::freeze</a>
    <li ><a href="#method-c-has_key-3F">::has_key?</a>
    <li ><a href="#method-c-has_value-3F">::has_value?</a>
    <li ><a href="#method-c-include-3F">::include?</a>
    <li ><a href="#method-c-inspect">::inspect</a>
    <li ><a href="#method-c-invert">::invert</a>
    <li ><a href="#method-c-keep_if">::keep_if</a>
    <li ><a href="#method-c-key">::key</a>
    <li ><a href="#method-c-key-3F">::key?</a>
    <li ><a href="#method-c-keys">::keys</a>
    <li ><a href="#method-c-length">::length</a>
    <li ><a href="#method-c-member-3F">::member?</a>
    <li ><a href="#method-c-merge-21">::merge!</a>
    <li ><a href="#method-c-rassoc">::rassoc</a>
    <li ><a href="#method-c-rehash">::rehash</a>
    <li ><a href="#method-c-reject">::reject</a>
    <li ><a href="#method-c-reject-21">::reject!</a>
    <li ><a href="#method-c-replace">::replace</a>
    <li ><a href="#method-c-select">::select</a>
    <li ><a href="#method-c-select-21">::select!</a>
    <li ><a href="#method-c-shift">::shift</a>
    <li ><a href="#method-c-size">::size</a>
    <li ><a href="#method-c-slice">::slice</a>
    <li ><a href="#method-c-store">::store</a>
    <li ><a href="#method-c-to_a">::to_a</a>
    <li ><a href="#method-c-to_h">::to_h</a>
    <li ><a href="#method-c-to_hash">::to_hash</a>
    <li ><a href="#method-c-to_s">::to_s</a>
    <li ><a href="#method-c-update">::update</a>
    <li ><a href="#method-c-value-3F">::value?</a>
    <li ><a href="#method-c-values">::values</a>
    <li ><a href="#method-c-values_at">::values_at</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-ENV">
    <h1 id="class-ENV" class="class">
      class ENV
    </h1>

    <section class="description">
    
<p>ENV is a hash-like accessor for environment variables.</p>

<h3 id="class-ENV-label-Interaction+with+the+Operating+System">Interaction with the Operating System<span><a href="#class-ENV-label-Interaction+with+the+Operating+System">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The ENV object interacts with the operating system’s environment variables:</p>
<ul><li>
<p>When you get the value for a name in ENV, the value is retrieved from among the current environment variables.</p>
</li><li>
<p>When you create or set a name-value pair in ENV, the name and value are immediately set in the environment variables.</p>
</li><li>
<p>When you delete a name-value pair in ENV, it is immediately deleted from the environment variables.</p>
</li></ul>

<h3 id="class-ENV-label-Names+and+Values">Names and Values<span><a href="#class-ENV-label-Names+and+Values">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Generally, a name or value is a <a href="String.html"><code>String</code></a>.</p>

<h4 id="class-ENV-label-Valid+Names+and+Values">Valid Names and Values<span><a href="#class-ENV-label-Valid+Names+and+Values">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Each name or value must be one of the following:</p>
<ul><li>
<p>A <a href="String.html"><code>String</code></a>.</p>
</li><li>
<p>An object that responds to #to_str by returning a <a href="String.html"><code>String</code></a>, in which case that <a href="String.html"><code>String</code></a> will be used as the name or value.</p>
</li></ul>

<h4 id="class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values<span><a href="#class-ENV-label-Invalid+Names+and+Values">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>A new name:</p>
<ul><li>
<p>May not be the empty string:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-comment"># Raises Errno::EINVAL (Invalid argument - ruby_setenv())</span>
</pre>
</li><li>
<p>May not contain character <code>&quot;=&quot;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;=&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-comment"># Raises Errno::EINVAL (Invalid argument - ruby_setenv(=))</span>
</pre>
</li></ul>

<p>A new name or value:</p>
<ul><li>
<p>May not be a non-String that does not respond to #to_str:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
<span class="ruby-comment"># Raises TypeError (no implicit conversion of Object into String)</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-comment"># Raises TypeError (no implicit conversion of Object into String)</span>
</pre>
</li><li>
<p>May not contain the NUL character <code>&quot;\0&quot;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&quot;\0&quot;</span>
<span class="ruby-comment"># Raises ArgumentError (bad environment variable value: contains null byte)</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;\0&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: contains null byte)</span>
</pre>
</li><li>
<p>May not have an ASCII-incompatible encoding such as UTF-16LE or ISO-2022-JP:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ISO_2022_JP</span>)
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP)</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;foo&quot;</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ISO_2022_JP</span>)] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP)</span>
</pre>
</li></ul>

<h3 id="class-ENV-label-About+Ordering">About Ordering<span><a href="#class-ENV-label-About+Ordering">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>ENV enumerates its name/value pairs in the order found in the operating system’s environment variables. Therefore the ordering of ENV content is OS-dependent, and may be indeterminate.</p>

<p>This will be seen in:</p>
<ul><li>
<p>A <a href="Hash.html"><code>Hash</code></a> returned by an ENV method.</p>
</li><li>
<p>An <a href="Enumerator.html"><code>Enumerator</code></a> returned by an ENV method.</p>
</li><li>
<p>An <a href="Array.html"><code>Array</code></a> returned by <a href="ENV.html#method-c-keys"><code>ENV.keys</code></a>, <a href="ENV.html#method-c-values"><code>ENV.values</code></a>, or <a href="ENV.html#method-c-to_a"><code>ENV.to_a</code></a>.</p>
</li><li>
<p>The <a href="String.html"><code>String</code></a> returned by <a href="ENV.html#method-c-inspect"><code>ENV.inspect</code></a>.</p>
</li><li>
<p>The <a href="Array.html"><code>Array</code></a> returned by <a href="ENV.html#method-c-shift"><code>ENV.shift</code></a>.</p>
</li><li>
<p>The name returned by <a href="ENV.html#method-c-key"><code>ENV.key</code></a>.</p>
</li></ul>

<h3 id="class-ENV-label-About+the+Examples">About the Examples<span><a href="#class-ENV-label-About+the+Examples">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Some methods in ENV return ENV itself. Typically, there are many environment variables. It’s not useful to display a large ENV in the examples here, so most example snippets begin by resetting the contents of ENV:</p>
<ul><li>
<p><a href="ENV.html#method-c-replace"><code>ENV.replace</code></a> replaces ENV with a new collection of entries.</p>
</li><li>
<p><a href="ENV.html#method-c-clear"><code>ENV.clear</code></a> empties ENV.</p>
</li></ul>

<h2 id="class-ENV-label-What-27s+Here">What’s Here<span><a href="#class-ENV-label-What-27s+Here">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>First, what’s elsewhere. Class ENV:</p>
<ul><li>
<p>Inherits from <a href="Object.html#class-Object-label-What-27s+Here">class Object</a>.</p>
</li><li>
<p>Extends <a href="Enumerable.html#module-Enumerable-label-What-27s+Here">module Enumerable</a>,</p>
</li></ul>

<p>Here, class ENV provides methods that are useful for:</p>
<ul><li>
<p><a href="ENV.html#class-ENV-label-Methods+for+Querying">Querying</a></p>
</li><li>
<p><a href="ENV.html#class-ENV-label-Methods+for+Assigning">Assigning</a></p>
</li><li>
<p><a href="ENV.html#class-ENV-label-Methods+for+Deleting">Deleting</a></p>
</li><li>
<p><a href="ENV.html#class-ENV-label-Methods+for+Iterating">Iterating</a></p>
</li><li>
<p><a href="ENV.html#class-ENV-label-Methods+for+Converting">Converting</a></p>
</li><li>
<p><a href="ENV.html#class-ENV-label-More+Methods">And more .…</a></p>
</li></ul>

<h3 id="class-ENV-label-Methods+for+Querying">Methods for Querying<span><a href="#class-ENV-label-Methods+for+Querying">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="ENV.html#method-c-5B-5D"><code>::[]</code></a>: Returns the value for the given environment variable name if it exists:</p>
</li><li>
<p><a href="ENV.html#method-c-empty-3F"><code>::empty?</code></a>: Returns whether ENV is empty.</p>
</li><li>
<p><a href="ENV.html#method-c-has_value-3F"><code>::has_value?</code></a>, <a href="ENV.html#method-c-value-3F"><code>::value?</code></a>: Returns whether the given value is in ENV.</p>
</li><li>
<p><a href="ENV.html#method-c-include-3F"><code>::include?</code></a>, <a href="ENV.html#method-c-has_key-3F"><code>::has_key?</code></a>, <a href="ENV.html#method-c-key-3F"><code>::key?</code></a>, <a href="ENV.html#method-c-member-3F"><code>::member?</code></a>: Returns whether the given name is in ENV.</p>
</li><li>
<p><a href="ENV.html#method-c-key"><code>::key</code></a>: Returns the name of the first entry with the given value.</p>
</li><li>
<p><a href="ENV.html#method-c-size"><code>::size</code></a>, <a href="ENV.html#method-c-length"><code>::length</code></a>: Returns the number of entries.</p>
</li><li>
<p><a href="ENV.html#method-c-value-3F"><code>::value?</code></a>: Returns whether any entry has the given value.</p>
</li></ul>

<h3 id="class-ENV-label-Methods+for+Assigning">Methods for Assigning<span><a href="#class-ENV-label-Methods+for+Assigning">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="ENV.html#method-c-5B-5D-3D"><code>::[]=</code></a>, <a href="ENV.html#method-c-store"><code>::store</code></a>: Creates, updates, or deletes the named environment variable.</p>
</li><li>
<p><a href="ENV.html#method-c-clear"><code>::clear</code></a>: Removes every environment variable; returns ENV:</p>
</li><li>
<p><a href="ENV.html#method-c-update"><code>::update</code></a>, <a href="ENV.html#method-c-merge-21"><code>::merge!</code></a>: Adds to ENV each key/value pair in the given hash.</p>
</li><li>
<p><a href="ENV.html#method-c-replace"><code>::replace</code></a>: Replaces the entire content of the ENV with the name/value pairs in the given hash.</p>
</li></ul>

<h3 id="class-ENV-label-Methods+for+Deleting">Methods for Deleting<span><a href="#class-ENV-label-Methods+for+Deleting">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="ENV.html#method-c-delete"><code>::delete</code></a>: Deletes the named environment variable name if it exists.</p>
</li><li>
<p><a href="ENV.html#method-c-delete_if"><code>::delete_if</code></a>: Deletes entries selected by the block.</p>
</li><li>
<p><a href="ENV.html#method-c-keep_if"><code>::keep_if</code></a>: Deletes entries not selected by the block.</p>
</li><li>
<p><a href="ENV.html#method-c-reject-21"><code>::reject!</code></a>: Similar to delete_if, but returns <code>nil</code> if no change was made.</p>
</li><li>
<p><a href="ENV.html#method-c-select-21"><code>::select!</code></a>, <a href="ENV.html#method-c-filter-21"><code>::filter!</code></a>: Deletes entries selected by the block.</p>
</li><li>
<p><a href="ENV.html#method-c-shift"><code>::shift</code></a>: Removes and returns the first entry.</p>
</li></ul>

<h3 id="class-ENV-label-Methods+for+Iterating">Methods for Iterating<span><a href="#class-ENV-label-Methods+for+Iterating">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="ENV.html#method-c-each"><code>::each</code></a>, <a href="ENV.html#method-c-each_pair"><code>::each_pair</code></a>: Calls the block with each name/value pair.</p>
</li><li>
<p><a href="ENV.html#method-c-each_key"><code>::each_key</code></a>: Calls the block with each name.</p>
</li><li>
<p><a href="ENV.html#method-c-each_value"><code>::each_value</code></a>: Calls the block with each value.</p>
</li></ul>

<h3 id="class-ENV-label-Methods+for+Converting">Methods for Converting<span><a href="#class-ENV-label-Methods+for+Converting">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="ENV.html#method-c-assoc"><code>::assoc</code></a>: Returns a 2-element array containing the name and value of the named environment variable if it exists:</p>
</li><li>
<p><a href="ENV.html#method-c-clone"><code>::clone</code></a>: Returns ENV (and issues a warning).</p>
</li><li>
<p><a href="ENV.html#method-c-except"><code>::except</code></a>: Returns a hash of all name/value pairs except those given.</p>
</li><li>
<p><a href="ENV.html#method-c-fetch"><code>::fetch</code></a>: Returns the value for the given name.</p>
</li><li>
<p><a href="ENV.html#method-c-inspect"><code>::inspect</code></a>: Returns the contents of ENV as a string.</p>
</li><li>
<p><a href="ENV.html#method-c-invert"><code>::invert</code></a>: Returns a hash whose keys are the ENV values, and whose values are the corresponding ENV names.</p>
</li><li>
<p><a href="ENV.html#method-c-keys"><code>::keys</code></a>: Returns an array of all names.</p>
</li><li>
<p><a href="ENV.html#method-c-rassoc"><code>::rassoc</code></a>: Returns the name and value of the first found entry that has the given value.</p>
</li><li>
<p><a href="ENV.html#method-c-reject"><code>::reject</code></a>: Returns a hash of those entries not rejected by the block.</p>
</li><li>
<p><a href="ENV.html#method-c-select"><code>::select</code></a>, <a href="ENV.html#method-c-filter"><code>::filter</code></a>: Returns a hash of name/value pairs selected by the block.</p>
</li><li>
<p><a href="ENV.html#method-c-slice"><code>::slice</code></a>: Returns a hash of the given names and their corresponding values.</p>
</li><li>
<p><a href="ENV.html#method-c-to_a"><code>::to_a</code></a>: Returns the entries as an array of 2-element Arrays.</p>
</li><li>
<p><a href="ENV.html#method-c-to_h"><code>::to_h</code></a>: Returns a hash of entries selected by the block.</p>
</li><li>
<p><a href="ENV.html#method-c-to_hash"><code>::to_hash</code></a>: Returns a hash of all entries.</p>
</li><li>
<p><a href="ENV.html#method-c-to_s"><code>::to_s</code></a>: Returns the string <code>&#39;ENV&#39;</code>.</p>
</li><li>
<p><a href="ENV.html#method-c-values"><code>::values</code></a>: Returns all values as an array.</p>
</li><li>
<p><a href="ENV.html#method-c-values_at"><code>::values_at</code></a>: Returns an array of the values for the given name.</p>
</li></ul>

<h3 id="class-ENV-label-More+Methods">More Methods<span><a href="#class-ENV-label-More+Methods">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="ENV.html#method-c-dup"><code>::dup</code></a>: Raises an exception.</p>
</li><li>
<p><a href="ENV.html#method-c-freeze"><code>::freeze</code></a>: Raises an exception.</p>
</li><li>
<p><a href="ENV.html#method-c-rehash"><code>::rehash</code></a>: Returns <code>nil</code>, without modifying ENV.</p>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-5B-5D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ENV[name] &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the value for the environment variable <code>name</code> if it exists:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] <span class="ruby-comment"># =&gt; &quot;0&quot;</span>
</pre>

<p>Returns <code>nil</code> if the named variable does not exist.</p>

<p>Raises an exception if <code>name</code> is invalid. See <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>.</p>

                              <div class="method-source-code" id="5B-5D-source">
            <pre>static VALUE
rb_f_getenv(VALUE obj, VALUE name)
{
    const char *nam = env_name(name);
    VALUE env = getenv_with_lock(nam);
    return env;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-5B-5D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ENV[name] = value      &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          store(name, value) &rarr; value
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates, updates, or deletes the named environment variable, returning the value. Both <code>name</code> and <code>value</code> may be instances of <a href="String.html"><code>String</code></a>. See <a href="ENV.html#class-ENV-label-Valid+Names+and+Values">Valid Names and Values</a>.</p>
<ul><li>
<p>If the named environment variable does not exist:</p>
<ul><li>
<p>If <code>value</code> is <code>nil</code>, does nothing.</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">clear</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-keyword">nil</span> <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;bar&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>
</li><li>
<p>If <code>value</code> is not <code>nil</code>, creates the environment variable with <code>name</code> and <code>value</code>:</p>

<pre class="ruby"><span class="ruby-comment"># Create &#39;foo&#39; using ENV.[]=.</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span> <span class="ruby-comment"># =&gt; &#39;0&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] <span class="ruby-comment"># =&gt; &#39;0&#39;</span>
<span class="ruby-comment"># Create &#39;bar&#39; using ENV.store.</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-string">&#39;1&#39;</span>) <span class="ruby-comment"># =&gt; &#39;1&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;bar&#39;</span>] <span class="ruby-comment"># =&gt; &#39;1&#39;</span>
</pre>
</li></ul>
</li><li>
<p>If the named environment variable exists:</p>
<ul><li>
<p>If <code>value</code> is not <code>nil</code>, updates the environment variable with value <code>value</code>:</p>

<pre class="ruby"><span class="ruby-comment"># Update &#39;foo&#39; using ENV.[]=.</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;2&#39;</span> <span class="ruby-comment"># =&gt; &#39;2&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] <span class="ruby-comment"># =&gt; &#39;2&#39;</span>
<span class="ruby-comment"># Update &#39;bar&#39; using ENV.store.</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-string">&#39;3&#39;</span>) <span class="ruby-comment"># =&gt; &#39;3&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;bar&#39;</span>] <span class="ruby-comment"># =&gt; &#39;3&#39;</span>
</pre>
</li><li>
<p>If <code>value</code> is <code>nil</code>, deletes the environment variable:</p>

<pre class="ruby"><span class="ruby-comment"># Delete &#39;foo&#39; using ENV.[]=.</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-keyword">nil</span> <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-comment"># Delete &#39;bar&#39; using ENV.store.</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;bar&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>
</li></ul>
</li></ul>

<p>Raises an exception if <code>name</code> or <code>value</code> is invalid. See <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>.</p>

                              <div class="method-source-code" id="5B-5D-3D-source">
            <pre>static VALUE
env_aset_m(VALUE obj, VALUE nm, VALUE val)
{
    return env_aset(nm, val);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-assoc" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          assoc(name) &rarr; [name, value] or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a 2-element <a href="Array.html"><code>Array</code></a> containing the name and value of the environment variable for <code>name</code> if it exists:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">assoc</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; [&#39;foo&#39;, &#39;0&#39;]</span>
</pre>

<p>Returns <code>nil</code> if <code>name</code> is a valid <a href="String.html"><code>String</code></a> and there is no such environment variable.</p>

<p>Returns <code>nil</code> if <code>name</code> is the empty <a href="String.html"><code>String</code></a> or is a <a href="String.html"><code>String</code></a> containing character <code>&#39;=&#39;</code>.</p>

<p>Raises an exception if <code>name</code> is a <a href="String.html"><code>String</code></a> containing the NUL character <code>&quot;\0&quot;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">assoc</span>(<span class="ruby-string">&quot;\0&quot;</span>) <span class="ruby-comment"># Raises ArgumentError (bad environment variable name: contains null byte)</span>
</pre>

<p>Raises an exception if <code>name</code> has an encoding that is not ASCII-compatible:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">assoc</span>(<span class="ruby-string">&quot;\xa1\xa1&quot;</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_16LE</span>))
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)</span>
</pre>

<p>Raises an exception if <code>name</code> is not a String:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">assoc</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>) <span class="ruby-comment"># TypeError (no implicit conversion of Object into String)</span>
</pre>

                              <div class="method-source-code" id="assoc-source">
            <pre>static VALUE
env_assoc(VALUE env, VALUE key)
{
    const char *s = env_name(key);
    VALUE e = getenv_with_lock(s);

    if (!NIL_P(e)) {
        return rb_assoc_new(key, e);
    }
    else {
        return Qnil;
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-clear" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          clear &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes every environment variable; returns ENV:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 2</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">clear</span> <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 0</span>
</pre>

                              <div class="method-source-code" id="clear-source">
            <pre>static VALUE
env_clear(VALUE _)
{
    return rb_env_clear();
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-clone" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          clone(freeze: nil) # raises TypeError
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Raises <a href="TypeError.html"><code>TypeError</code></a>, because <a href="ENV.html"><code>ENV</code></a> is a wrapper for the process-wide environment variables and a clone is useless. Use to_h to get a copy of <a href="ENV.html"><code>ENV</code></a> data as a hash.</p>

                              <div class="method-source-code" id="clone-source">
            <pre>static VALUE
env_clone(int argc, VALUE *argv, VALUE obj)
{
    if (argc) {
        VALUE opt;
        if (rb_scan_args(argc, argv, &quot;0:&quot;, &amp;opt) &lt; argc) {
            rb_get_freeze_opt(1, &amp;opt);
        }
    }

    rb_raise(rb_eTypeError, &quot;Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-delete" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete(name)                           &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete(name) { |name| block }          &rarr; value
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete(missing_name)                   &rarr; nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete(missing_name) { |name| block }  &rarr; block_value
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Deletes the environment variable with <code>name</code> if it exists and returns its value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; &#39;0&#39;</span>
</pre>

<p>If a block is not given and the named environment variable does not exist, returns <code>nil</code>.</p>

<p>If a block given and the environment variable does not exist, yields <code>name</code> to the block and returns the value of the block:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;foo&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">*</span> <span class="ruby-value">2</span> } <span class="ruby-comment"># =&gt; &quot;foofoo&quot;</span>
</pre>

<p>If a block given and the environment variable exists, deletes the environment variable and returns its value (ignoring the block):</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;foo&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">raise</span> <span class="ruby-string">&#39;ignored&#39;</span> } <span class="ruby-comment"># =&gt; &quot;0&quot;</span>
</pre>

<p>Raises an exception if <code>name</code> is invalid. See <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>.</p>

                              <div class="method-source-code" id="delete-source">
            <pre>static VALUE
env_delete_m(VALUE obj, VALUE name)
{
    VALUE val;

    val = env_delete(name);
    if (NIL_P(val) &amp;&amp; rb_block_given_p()) val = rb_yield(name);
    return val;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-delete_if" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete_if { |name, value| block } &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete_if                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>, deleting each environment variable for which the block returns a truthy value, and returning <a href="ENV.html"><code>ENV</code></a> (regardless of whether any deletions):</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;foo&quot;=&gt;&quot;0&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete_if</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:delete_if!&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;foo&quot;=&gt;&quot;0&quot;}</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
</pre>

                              <div class="method-source-code" id="delete_if-source">
            <pre>static VALUE
env_delete_if(VALUE ehash)
{
    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    env_reject_bang(ehash);
    return envtbl;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-dup" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          dup # raises TypeError
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Raises <a href="TypeError.html"><code>TypeError</code></a>, because <a href="ENV.html"><code>ENV</code></a> is a singleton object. Use to_h to get a copy of <a href="ENV.html"><code>ENV</code></a> data as a hash.</p>

                              <div class="method-source-code" id="dup-source">
            <pre>static VALUE
env_dup(VALUE obj)
{
    rb_raise(rb_eTypeError, &quot;Cannot dup ENV, use ENV.to_h to get a copy of ENV as a hash&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-each" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each      { |name, value| block } &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each                              &rarr; an_enumerator
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_pair { |name, value| block } &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_pair                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element Array:</p>

<pre class="ruby"><span class="ruby-identifier">h</span> = {}
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span> } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">h</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-identifier">h</span> = {}
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:each_pair&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span> } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">h</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

                              <div class="method-source-code" id="each-source">
            <pre>static VALUE
env_each_pair(VALUE ehash)
{
    long i;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);

    VALUE ary = rb_ary_new();

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);

        while (*env) {
            char *s = strchr(*env, &#39;=&#39;);
            if (s) {
                rb_ary_push(ary, env_str_new(*env, s-*env));
                rb_ary_push(ary, env_str_new2(s+1));
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    if (rb_block_pair_yield_optimizable()) {
        for (i=0; i&lt;RARRAY_LEN(ary); i+=2) {
            rb_yield_values(2, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1));
        }
    }
    else {
        for (i=0; i&lt;RARRAY_LEN(ary); i+=2) {
            rb_yield(rb_assoc_new(RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)));
        }
    }

    return ehash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-each_key" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_key { |name| block } &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_key                  &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>) <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">names</span> = []
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_key</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">name</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">names</span> <span class="ruby-comment"># =&gt; [&quot;bar&quot;, &quot;foo&quot;]</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:each_key&gt;</span>
<span class="ruby-identifier">names</span> = []
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">name</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">names</span> <span class="ruby-comment"># =&gt; [&quot;bar&quot;, &quot;foo&quot;]</span>
</pre>

                              <div class="method-source-code" id="each_key-source">
            <pre>static VALUE
env_each_key(VALUE ehash)
{
    VALUE keys;
    long i;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    keys = env_keys(FALSE);
    for (i=0; i&lt;RARRAY_LEN(keys); i++) {
        rb_yield(RARRAY_AREF(keys, i));
    }
    return ehash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-each_pair" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each      { |name, value| block } &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each                              &rarr; an_enumerator
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_pair { |name, value| block } &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_pair                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element Array:</p>

<pre class="ruby"><span class="ruby-identifier">h</span> = {}
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span> } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">h</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-identifier">h</span> = {}
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:each_pair&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span> } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">h</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

                              <div class="method-source-code" id="each_pair-source">
            <pre>static VALUE
env_each_pair(VALUE ehash)
{
    long i;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);

    VALUE ary = rb_ary_new();

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);

        while (*env) {
            char *s = strchr(*env, &#39;=&#39;);
            if (s) {
                rb_ary_push(ary, env_str_new(*env, s-*env));
                rb_ary_push(ary, env_str_new2(s+1));
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    if (rb_block_pair_yield_optimizable()) {
        for (i=0; i&lt;RARRAY_LEN(ary); i+=2) {
            rb_yield_values(2, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1));
        }
    }
    else {
        for (i=0; i&lt;RARRAY_LEN(ary); i+=2) {
            rb_yield(rb_assoc_new(RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)));
        }
    }

    return ehash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-each_value" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_value { |value| block } &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_value                   &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>) <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">values</span> = []
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">value</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">values</span> <span class="ruby-comment"># =&gt; [&quot;1&quot;, &quot;0&quot;]</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:each_value&gt;</span>
<span class="ruby-identifier">values</span> = []
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">value</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-identifier">values</span> <span class="ruby-comment"># =&gt; [&quot;1&quot;, &quot;0&quot;]</span>
</pre>

                              <div class="method-source-code" id="each_value-source">
            <pre>static VALUE
env_each_value(VALUE ehash)
{
    VALUE values;
    long i;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    values = env_values();
    for (i=0; i&lt;RARRAY_LEN(values); i++) {
        rb_yield(RARRAY_AREF(values, i));
    }
    return ehash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-empty-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          empty? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> when there are no environment variables, <code>false</code> otherwise:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">clear</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="empty-3F-source">
            <pre>static VALUE
env_empty_p(VALUE _)
{
    bool empty = true;

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);
        if (env[0] != 0) {
            empty = false;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    return RBOOL(empty);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-except" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          except(*keys) &rarr; a_hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash except the given keys from <a href="ENV.html"><code>ENV</code></a> and their values.</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>                       <span class="ruby-comment">#=&gt; {&quot;LANG&quot;=&gt;&quot;en_US.UTF-8&quot;, &quot;TERM&quot;=&gt;&quot;xterm-256color&quot;, &quot;HOME&quot;=&gt;&quot;/Users/rhc&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">except</span>(<span class="ruby-string">&quot;TERM&quot;</span>,<span class="ruby-string">&quot;HOME&quot;</span>) <span class="ruby-comment">#=&gt; {&quot;LANG&quot;=&gt;&quot;en_US.UTF-8&quot;}</span>
</pre>

                              <div class="method-source-code" id="except-source">
            <pre>static VALUE
env_except(int argc, VALUE *argv, VALUE _)
{
    int i;
    VALUE key, hash = env_to_hash();

    for (i = 0; i &lt; argc; i++) {
        key = argv[i];
        rb_hash_delete(hash, key);
    }

    return hash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-fetch" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          fetch(name)                  &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          fetch(name, default)         &rarr; value
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          fetch(name) { |name| block } &rarr; value
                              </span>
                            </div>

                            <div class="method-description">
                              <p>If <code>name</code> is the name of an environment variable, returns its value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; &#39;0&#39;</span>
</pre>

<p>Otherwise if a block is given (but not a default value), yields <code>name</code> to the block and returns the block’s return value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-string">&#39;foo&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-value">:need_not_return_a_string</span> } <span class="ruby-comment"># =&gt; :need_not_return_a_string</span>
</pre>

<p>Otherwise if a default value is given (but not a block), returns the default value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;foo&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-value">:default_need_not_be_a_string</span>) <span class="ruby-comment"># =&gt; :default_need_not_be_a_string</span>
</pre>

<p>If the environment variable does not exist and both default and block are given, issues a warning (“warning: block supersedes default value argument”), yields <code>name</code> to the block, and returns the block’s return value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-value">:default</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-value">:block_return</span> } <span class="ruby-comment"># =&gt; :block_return</span>
</pre>

<p>Raises <a href="KeyError.html"><code>KeyError</code></a> if <code>name</code> is valid, but not found, and neither default value nor block is given:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># Raises KeyError (key not found: &quot;foo&quot;)</span>
</pre>

<p>Raises an exception if <code>name</code> is invalid. See <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>.</p>

                              <div class="method-source-code" id="fetch-source">
            <pre>static VALUE
env_fetch(int argc, VALUE *argv, VALUE _)
{
    VALUE key;
    long block_given;
    const char *nam;
    VALUE env;

    rb_check_arity(argc, 1, 2);
    key = argv[0];
    block_given = rb_block_given_p();
    if (block_given &amp;&amp; argc == 2) {
        rb_warn(&quot;block supersedes default value argument&quot;);
    }
    nam = env_name(key);
    env = getenv_with_lock(nam);

    if (NIL_P(env)) {
        if (block_given) return rb_yield(key);
        if (argc == 1) {
            rb_key_err_raise(rb_sprintf(&quot;key not found: \&quot;%&quot;PRIsVALUE&quot;\&quot;&quot;, key), envtbl, key);
        }
        return argv[1];
    }
    return env;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-filter" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          select { |name, value| block } &rarr; hash of name/value pairs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          select                         &rarr; an_enumerator
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter { |name, value| block } &rarr; hash of name/value pairs
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>, returning a <a href="Hash.html"><code>Hash</code></a> of the names and values for which the block returns a truthy value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:select&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:filter&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
</pre>

                              <div class="method-source-code" id="filter-source">
            <pre>static VALUE
env_select(VALUE ehash)
{
    VALUE result;
    VALUE keys;
    long i;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    result = rb_hash_new();
    keys = env_keys(FALSE);
    for (i = 0; i &lt; RARRAY_LEN(keys); ++i) {
        VALUE key = RARRAY_AREF(keys, i);
        VALUE val = rb_f_getenv(Qnil, key);
        if (!NIL_P(val)) {
            if (RTEST(rb_yield_values(2, key, val))) {
                rb_hash_aset(result, key, val);
            }
        }
    }
    RB_GC_GUARD(keys);

    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-filter-21" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          select! { |name, value| block } &rarr; ENV or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          select!                         &rarr; an_enumerator
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter! { |name, value| block } &rarr; ENV or nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter!                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>, deleting each entry for which the block returns <code>false</code> or <code>nil</code>, and returning <a href="ENV.html"><code>ENV</code></a> if any deletions made, or <code>nil</code> otherwise:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>

<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select!</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}:select!&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>

<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter!</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}:filter!&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>
</pre>

                              <div class="method-source-code" id="filter-21-source">
            <pre>static VALUE
env_select_bang(VALUE ehash)
{
    VALUE keys;
    long i;
    int del = 0;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    keys = env_keys(FALSE);
    RBASIC_CLEAR_CLASS(keys);
    for (i=0; i&lt;RARRAY_LEN(keys); i++) {
        VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i));
        if (!NIL_P(val)) {
            if (!RTEST(rb_yield_values(2, RARRAY_AREF(keys, i), val))) {
                env_delete(RARRAY_AREF(keys, i));
                del++;
            }
        }
    }
    RB_GC_GUARD(keys);
    if (del == 0) return Qnil;
    return envtbl;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-freeze" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          freeze
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Raises an exception:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">freeze</span> <span class="ruby-comment"># Raises TypeError (cannot freeze ENV)</span>
</pre>

                              <div class="method-source-code" id="freeze-source">
            <pre>static VALUE
env_freeze(VALUE self)
{
    rb_raise(rb_eTypeError, &quot;cannot freeze ENV&quot;);
    UNREACHABLE_RETURN(self);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-has_key-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          include?(name) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          has_key?(name) &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          member?(name)  &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          key?(name)     &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if there is an environment variable with the given <code>name</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is a valid <a href="String.html"><code>String</code></a> and there is no such environment variable:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;baz&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is the empty <a href="String.html"><code>String</code></a> or is a <a href="String.html"><code>String</code></a> containing character <code>&#39;=&#39;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;=&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Raises an exception if <code>name</code> is a <a href="String.html"><code>String</code></a> containing the NUL character <code>&quot;\0&quot;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\0&quot;</span>) <span class="ruby-comment"># Raises ArgumentError (bad environment variable name: contains null byte)</span>
</pre>

<p>Raises an exception if <code>name</code> has an encoding that is not ASCII-compatible:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\xa1\xa1&quot;</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_16LE</span>))
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)</span>
</pre>

<p>Raises an exception if <code>name</code> is not a String:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>) <span class="ruby-comment"># TypeError (no implicit conversion of Object into String)</span>
</pre>

                              <div class="method-source-code" id="has_key-3F-source">
            <pre>static VALUE
env_has_key(VALUE env, VALUE key)
{
    const char *s = env_name(key);
    return RBOOL(has_env_with_lock(s));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-has_value-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          value?(value)     &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          has_value?(value) &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>value</code> is the value for some environment variable name, <code>false</code> otherwise:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">value?</span>(<span class="ruby-string">&#39;0&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">has_value?</span>(<span class="ruby-string">&#39;0&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">value?</span>(<span class="ruby-string">&#39;2&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">has_value?</span>(<span class="ruby-string">&#39;2&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="has_value-3F-source">
            <pre>static VALUE
env_has_value(VALUE dmy, VALUE obj)
{
    obj = rb_check_string_type(obj);
    if (NIL_P(obj)) return Qnil;

    VALUE ret = Qfalse;

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);
        while (*env) {
            char *s = strchr(*env, &#39;=&#39;);
            if (s++) {
                long len = strlen(s);
                if (RSTRING_LEN(obj) == len &amp;&amp; strncmp(s, RSTRING_PTR(obj), len) == 0) {
                    ret = Qtrue;
                    break;
                }
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    return ret;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-include-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          include?(name) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          has_key?(name) &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          member?(name)  &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          key?(name)     &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if there is an environment variable with the given <code>name</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is a valid <a href="String.html"><code>String</code></a> and there is no such environment variable:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;baz&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is the empty <a href="String.html"><code>String</code></a> or is a <a href="String.html"><code>String</code></a> containing character <code>&#39;=&#39;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;=&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Raises an exception if <code>name</code> is a <a href="String.html"><code>String</code></a> containing the NUL character <code>&quot;\0&quot;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\0&quot;</span>) <span class="ruby-comment"># Raises ArgumentError (bad environment variable name: contains null byte)</span>
</pre>

<p>Raises an exception if <code>name</code> has an encoding that is not ASCII-compatible:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\xa1\xa1&quot;</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_16LE</span>))
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)</span>
</pre>

<p>Raises an exception if <code>name</code> is not a String:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>) <span class="ruby-comment"># TypeError (no implicit conversion of Object into String)</span>
</pre>

                              <div class="method-source-code" id="include-3F-source">
            <pre>static VALUE
env_has_key(VALUE env, VALUE key)
{
    const char *s = env_name(key);
    return RBOOL(has_env_with_lock(s));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-inspect" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          inspect &rarr; a_string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the contents of the environment as a String:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">inspect</span> <span class="ruby-comment"># =&gt; &quot;{\&quot;bar\&quot;=&gt;\&quot;1\&quot;, \&quot;foo\&quot;=&gt;\&quot;0\&quot;}&quot;</span>
</pre>

                              <div class="method-source-code" id="inspect-source">
            <pre>static VALUE
env_inspect(VALUE _)
{
    VALUE i;
    VALUE str = rb_str_buf_new2(&quot;{&quot;);

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);
        while (*env) {
            char *s = strchr(*env, &#39;=&#39;);

            if (env != environ) {
                rb_str_buf_cat2(str, &quot;, &quot;);
            }
            if (s) {
                rb_str_buf_cat2(str, &quot;\&quot;&quot;);
                rb_str_buf_cat(str, *env, s-*env);
                rb_str_buf_cat2(str, &quot;\&quot;=&gt;&quot;);
                i = rb_inspect(rb_str_new2(s+1));
                rb_str_buf_append(str, i);
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    rb_str_buf_cat2(str, &quot;}&quot;);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-invert" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          invert &rarr; hash of value/name pairs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a <a href="Hash.html"><code>Hash</code></a> whose keys are the <a href="ENV.html"><code>ENV</code></a> values, and whose values are the corresponding <a href="ENV.html"><code>ENV</code></a> names:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">invert</span> <span class="ruby-comment"># =&gt; {&quot;1&quot;=&gt;&quot;bar&quot;, &quot;0&quot;=&gt;&quot;foo&quot;}</span>
</pre>

<p>For a duplicate <a href="ENV.html"><code>ENV</code></a> value, overwrites the hash entry:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">invert</span> <span class="ruby-comment"># =&gt; {&quot;0&quot;=&gt;&quot;foo&quot;}</span>
</pre>

<p>Note that the order of the <a href="ENV.html"><code>ENV</code></a> processing is OS-dependent, which means that the order of overwriting is also OS-dependent. See <a href="ENV.html#class-ENV-label-About+Ordering">About Ordering</a>.</p>

                              <div class="method-source-code" id="invert-source">
            <pre>static VALUE
env_invert(VALUE _)
{
    return rb_hash_invert(env_to_hash());
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-keep_if" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          keep_if { |name, value| block } &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          keep_if                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>, deleting each environment variable for which the block returns <code>false</code> or <code>nil</code>, and returning ENV:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">keep_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">keep_if</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:keep_if&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
</pre>

                              <div class="method-source-code" id="keep_if-source">
            <pre>static VALUE
env_keep_if(VALUE ehash)
{
    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    env_select_bang(ehash);
    return envtbl;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-key" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          key(value) &rarr; name or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the name of the first environment variable with <code>value</code>, if it exists:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">key</span>(<span class="ruby-string">&#39;0&#39;</span>) <span class="ruby-comment"># =&gt; &quot;foo&quot;</span>
</pre>

<p>The order in which environment variables are examined is OS-dependent. See <a href="ENV.html#class-ENV-label-About+Ordering">About Ordering</a>.</p>

<p>Returns <code>nil</code> if there is no such value.</p>

<p>Raises an exception if <code>value</code> is invalid:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">key</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>) <span class="ruby-comment"># raises TypeError (no implicit conversion of Object into String)</span>
</pre>

<p>See <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>.</p>

                              <div class="method-source-code" id="key-source">
            <pre>static VALUE
env_key(VALUE dmy, VALUE value)
{
    SafeStringValue(value);
    VALUE str = Qnil;

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);
        while (*env) {
            char *s = strchr(*env, &#39;=&#39;);
            if (s++) {
                long len = strlen(s);
                if (RSTRING_LEN(value) == len &amp;&amp; strncmp(s, RSTRING_PTR(value), len) == 0) {
                    str = env_str_new(*env, s-*env-1);
                    break;
                }
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-key-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          include?(name) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          has_key?(name) &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          member?(name)  &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          key?(name)     &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if there is an environment variable with the given <code>name</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is a valid <a href="String.html"><code>String</code></a> and there is no such environment variable:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;baz&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is the empty <a href="String.html"><code>String</code></a> or is a <a href="String.html"><code>String</code></a> containing character <code>&#39;=&#39;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;=&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Raises an exception if <code>name</code> is a <a href="String.html"><code>String</code></a> containing the NUL character <code>&quot;\0&quot;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\0&quot;</span>) <span class="ruby-comment"># Raises ArgumentError (bad environment variable name: contains null byte)</span>
</pre>

<p>Raises an exception if <code>name</code> has an encoding that is not ASCII-compatible:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\xa1\xa1&quot;</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_16LE</span>))
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)</span>
</pre>

<p>Raises an exception if <code>name</code> is not a String:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>) <span class="ruby-comment"># TypeError (no implicit conversion of Object into String)</span>
</pre>

                              <div class="method-source-code" id="key-3F-source">
            <pre>static VALUE
env_has_key(VALUE env, VALUE key)
{
    const char *s = env_name(key);
    return RBOOL(has_env_with_lock(s));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-keys" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          keys &rarr; array of names
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns all variable names in an Array:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">keys</span> <span class="ruby-comment"># =&gt; [&#39;bar&#39;, &#39;foo&#39;]</span>
</pre>

<p>The order of the names is OS-dependent. See <a href="ENV.html#class-ENV-label-About+Ordering">About Ordering</a>.</p>

<p>Returns the empty <a href="Array.html"><code>Array</code></a> if <a href="ENV.html"><code>ENV</code></a> is empty.</p>

                              <div class="method-source-code" id="keys-source">
            <pre>static VALUE
env_f_keys(VALUE _)
{
    return env_keys(FALSE);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-length" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          length &rarr; an_integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          size   &rarr; an_integer
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the count of environment variables:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">length</span> <span class="ruby-comment"># =&gt; 2</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 2</span>
</pre>

                              <div class="method-source-code" id="length-source">
            <pre>static VALUE
env_size(VALUE _)
{
    return INT2FIX(env_size_with_lock());
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-member-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          include?(name) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          has_key?(name) &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          member?(name)  &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          key?(name)     &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if there is an environment variable with the given <code>name</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is a valid <a href="String.html"><code>String</code></a> and there is no such environment variable:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;baz&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Returns <code>false</code> if <code>name</code> is the empty <a href="String.html"><code>String</code></a> or is a <a href="String.html"><code>String</code></a> containing character <code>&#39;=&#39;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;=&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Raises an exception if <code>name</code> is a <a href="String.html"><code>String</code></a> containing the NUL character <code>&quot;\0&quot;</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\0&quot;</span>) <span class="ruby-comment"># Raises ArgumentError (bad environment variable name: contains null byte)</span>
</pre>

<p>Raises an exception if <code>name</code> has an encoding that is not ASCII-compatible:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\xa1\xa1&quot;</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_16LE</span>))
<span class="ruby-comment"># Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)</span>
</pre>

<p>Raises an exception if <code>name</code> is not a String:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>) <span class="ruby-comment"># TypeError (no implicit conversion of Object into String)</span>
</pre>

                              <div class="method-source-code" id="member-3F-source">
            <pre>static VALUE
env_has_key(VALUE env, VALUE key)
{
    const char *s = env_name(key);
    return RBOOL(has_env_with_lock(s));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-merge-21" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          update                                              &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          update(*hashes)                                     &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          update(*hashes) { |name, env_val, hash_val| block } &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          merge!                                              &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          merge!(*hashes)                                     &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          merge!(*hashes) { |name, env_val, hash_val| block } &rarr; ENV
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Adds to <a href="ENV.html"><code>ENV</code></a> each key/value pair in the given <code>hash</code>; returns ENV:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>, <span class="ruby-string">&#39;bat&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;3&#39;</span>) <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;bat&quot;=&gt;&quot;3&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>Deletes the <a href="ENV.html"><code>ENV</code></a> entry for a hash value that is <code>nil</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">nil</span>, <span class="ruby-string">&#39;bat&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>For an already-existing name, if no block given, overwrites the <a href="ENV.html"><code>ENV</code></a> value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;4&#39;</span>) <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;4&quot;}</span>
</pre>

<p>For an already-existing name, if block given, yields the name, its <a href="ENV.html"><code>ENV</code></a> value, and its hash value; the block’s return value becomes the new name:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;5&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">env_val</span>, <span class="ruby-identifier">hash_val</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">env_val</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">hash_val</span> } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;45&quot;}</span>
</pre>

<p>Raises an exception if a name or value is invalid (see <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>);</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;6&#39;</span>, <span class="ruby-value">:bar</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;7&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;9&#39;</span>) <span class="ruby-comment"># Raises TypeError (no implicit conversion of Symbol into String)</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;6&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;7&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">8</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;9&#39;</span>) <span class="ruby-comment"># Raises TypeError (no implicit conversion of Integer into String)</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;7&quot;}</span>
</pre>

<p>Raises an exception if the block returns an invalid name: (see <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>):</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;bat&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;8&#39;</span>, <span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;9&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">env_val</span>, <span class="ruby-identifier">hash_val</span> <span class="ruby-operator">|</span> <span class="ruby-value">10</span> } <span class="ruby-comment"># Raises TypeError (no implicit conversion of Integer into String)</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;bat&quot;=&gt;&quot;8&quot;, &quot;foo&quot;=&gt;&quot;7&quot;}</span>
</pre>

<p>Note that for the exceptions above, hash pairs preceding an invalid name or value are processed normally; those following are ignored.</p>

                              <div class="method-source-code" id="merge-21-source">
            <pre>static VALUE
env_update(int argc, VALUE *argv, VALUE env)
{
    rb_foreach_func *func = rb_block_given_p() ?
        env_update_block_i : env_update_i;
    for (int i = 0; i &lt; argc; ++i) {
        VALUE hash = argv[i];
        if (env == hash) continue;
        hash = to_hash(hash);
        rb_hash_foreach(hash, func, 0);
    }
    return env;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-rassoc" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          rassoc(value) &rarr; [name, value] or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a 2-element <a href="Array.html"><code>Array</code></a> containing the name and value of the <strong>first</strong> <strong>found</strong> environment variable that has value <code>value</code>, if one exists:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">rassoc</span>(<span class="ruby-string">&#39;0&#39;</span>) <span class="ruby-comment"># =&gt; [&quot;bar&quot;, &quot;0&quot;]</span>
</pre>

<p>The order in which environment variables are examined is OS-dependent. See <a href="ENV.html#class-ENV-label-About+Ordering">About Ordering</a>.</p>

<p>Returns <code>nil</code> if there is no such environment variable.</p>

                              <div class="method-source-code" id="rassoc-source">
            <pre>static VALUE
env_rassoc(VALUE dmy, VALUE obj)
{
    obj = rb_check_string_type(obj);
    if (NIL_P(obj)) return Qnil;

    VALUE result = Qnil;

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);

        while (*env) {
            const char *p = *env;
            char *s = strchr(p, &#39;=&#39;);
            if (s++) {
                long len = strlen(s);
                if (RSTRING_LEN(obj) == len &amp;&amp; strncmp(s, RSTRING_PTR(obj), len) == 0) {
                    result = rb_assoc_new(rb_str_new(p, s-p-1), obj);
                    break;
                }
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-rehash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          rehash &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>(Provided for compatibility with <a href="Hash.html"><code>Hash</code></a>.)</p>

<p>Does not modify <a href="ENV.html"><code>ENV</code></a>; returns <code>nil</code>.</p>

                              <div class="method-source-code" id="rehash-source">
            <pre>static VALUE
env_none(VALUE _)
{
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-reject" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          reject { |name, value| block } &rarr; hash of name/value pairs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          reject                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>. Returns a <a href="Hash.html"><code>Hash</code></a> whose items are determined by the block. When the block returns a truthy value, the name/value pair is added to the return <a href="Hash.html"><code>Hash</code></a>; otherwise the pair is ignored:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">reject</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

                              <div class="method-source-code" id="reject-source">
            <pre>static VALUE
env_reject(VALUE _)
{
    return rb_hash_delete_if(env_to_hash());
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-reject-21" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          reject! { |name, value| block } &rarr; ENV or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          reject!                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Similar to <a href="ENV.html#method-c-delete_if"><code>ENV.delete_if</code></a>, but returns <code>nil</code> if no changes were made.</p>

<p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>, deleting each environment variable for which the block returns a truthy value, and returning <a href="ENV.html"><code>ENV</code></a> (if any deletions) or <code>nil</code> (if not):</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;foo&quot;=&gt;&quot;0&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">reject!</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:reject!&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;foo&quot;=&gt;&quot;0&quot;}</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; nil</span>
</pre>

                              <div class="method-source-code" id="reject-21-source">
            <pre>static VALUE
env_reject_bang(VALUE ehash)
{
    VALUE keys;
    long i;
    int del = 0;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    keys = env_keys(FALSE);
    RBASIC_CLEAR_CLASS(keys);
    for (i=0; i&lt;RARRAY_LEN(keys); i++) {
        VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i));
        if (!NIL_P(val)) {
            if (RTEST(rb_yield_values(2, RARRAY_AREF(keys, i), val))) {
                env_delete(RARRAY_AREF(keys, i));
                del++;
            }
        }
    }
    RB_GC_GUARD(keys);
    if (del == 0) return Qnil;
    return envtbl;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-replace" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          replace(hash) &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Replaces the entire content of the environment variables with the name/value pairs in the given <code>hash</code>; returns <a href="ENV.html"><code>ENV</code></a>.</p>

<p>Replaces the content of <a href="ENV.html"><code>ENV</code></a> with the given pairs:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>) <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>Raises an exception if a name or value is invalid (see <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>):</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-value">:bar</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>) <span class="ruby-comment"># Raises TypeError (no implicit conversion of Symbol into String)</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">1</span>) <span class="ruby-comment"># Raises TypeError (no implicit conversion of Integer into String)</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

                              <div class="method-source-code" id="replace-source">
            <pre>static VALUE
env_replace(VALUE env, VALUE hash)
{
    VALUE keys;
    long i;

    keys = env_keys(TRUE);
    if (env == hash) return env;
    hash = to_hash(hash);
    rb_hash_foreach(hash, env_replace_i, keys);

    for (i=0; i&lt;RARRAY_LEN(keys); i++) {
        env_delete(RARRAY_AREF(keys, i));
    }
    RB_GC_GUARD(keys);
    return env;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-select" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          select { |name, value| block } &rarr; hash of name/value pairs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          select                         &rarr; an_enumerator
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter { |name, value| block } &rarr; hash of name/value pairs
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>, returning a <a href="Hash.html"><code>Hash</code></a> of the names and values for which the block returns a truthy value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:select&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}:filter&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
</pre>

                              <div class="method-source-code" id="select-source">
            <pre>static VALUE
env_select(VALUE ehash)
{
    VALUE result;
    VALUE keys;
    long i;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    result = rb_hash_new();
    keys = env_keys(FALSE);
    for (i = 0; i &lt; RARRAY_LEN(keys); ++i) {
        VALUE key = RARRAY_AREF(keys, i);
        VALUE val = rb_f_getenv(Qnil, key);
        if (!NIL_P(val)) {
            if (RTEST(rb_yield_values(2, key, val))) {
                rb_hash_aset(result, key, val);
            }
        }
    }
    RB_GC_GUARD(keys);

    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-select-21" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          select! { |name, value| block } &rarr; ENV or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          select!                         &rarr; an_enumerator
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter! { |name, value| block } &rarr; ENV or nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          filter!                         &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Yields each environment variable name and its value as a 2-element <a href="Array.html"><code>Array</code></a>, deleting each entry for which the block returns <code>false</code> or <code>nil</code>, and returning <a href="ENV.html"><code>ENV</code></a> if any deletions made, or <code>nil</code> otherwise:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>

<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>Returns an <a href="Enumerator.html"><code>Enumerator</code></a> if no block given:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">select!</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}:select!&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>

<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">filter!</span> <span class="ruby-comment"># =&gt; #&lt;Enumerator: {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}:filter!&gt;</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;b&#39;</span>) } <span class="ruby-comment"># =&gt; ENV</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-keyword">true</span> } <span class="ruby-comment"># =&gt; nil</span>
</pre>

                              <div class="method-source-code" id="select-21-source">
            <pre>static VALUE
env_select_bang(VALUE ehash)
{
    VALUE keys;
    long i;
    int del = 0;

    RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
    keys = env_keys(FALSE);
    RBASIC_CLEAR_CLASS(keys);
    for (i=0; i&lt;RARRAY_LEN(keys); i++) {
        VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i));
        if (!NIL_P(val)) {
            if (!RTEST(rb_yield_values(2, RARRAY_AREF(keys, i), val))) {
                env_delete(RARRAY_AREF(keys, i));
                del++;
            }
        }
    }
    RB_GC_GUARD(keys);
    if (del == 0) return Qnil;
    return envtbl;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-shift" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          shift &rarr; [name, value] or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the first environment variable from <a href="ENV.html"><code>ENV</code></a> and returns a 2-element <a href="Array.html"><code>Array</code></a> containing its name and value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span> <span class="ruby-comment"># =&gt; {&#39;bar&#39; =&gt; &#39;1&#39;, &#39;foo&#39; =&gt; &#39;0&#39;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment"># =&gt; [&#39;bar&#39;, &#39;1&#39;]</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span> <span class="ruby-comment"># =&gt; {&#39;foo&#39; =&gt; &#39;0&#39;}</span>
</pre>

<p>Exactly which environment variable is “first” is OS-dependent. See <a href="ENV.html#class-ENV-label-About+Ordering">About Ordering</a>.</p>

<p>Returns <code>nil</code> if the environment is empty.</p>

                              <div class="method-source-code" id="shift-source">
            <pre>static VALUE
env_shift(VALUE _)
{
    VALUE result = Qnil;
    VALUE key = Qnil;

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);
        if (*env) {
            const char *p = *env;
            char *s = strchr(p, &#39;=&#39;);
            if (s) {
                key = env_str_new(p, s-p);
                VALUE val = env_str_new2(getenv(RSTRING_PTR(key)));
                result = rb_assoc_new(key, val);
            }
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    if (!NIL_P(key)) {
        env_delete(key);
    }

    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-size" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          length &rarr; an_integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          size   &rarr; an_integer
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the count of environment variables:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">length</span> <span class="ruby-comment"># =&gt; 2</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 2</span>
</pre>

                              <div class="method-source-code" id="size-source">
            <pre>static VALUE
env_size(VALUE _)
{
    return INT2FIX(env_size_with_lock());
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-slice" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          slice(*names) &rarr; hash of name/value pairs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a <a href="Hash.html"><code>Hash</code></a> of the given <a href="ENV.html"><code>ENV</code></a> names and their corresponding values:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>, <span class="ruby-string">&#39;bat&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;3&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span>) <span class="ruby-comment"># =&gt; {&quot;foo&quot;=&gt;&quot;0&quot;, &quot;baz&quot;=&gt;&quot;2&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-string">&#39;baz&#39;</span>, <span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; {&quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>Raises an exception if any of the <code>names</code> is invalid (see <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>):</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-value">:bat</span>) <span class="ruby-comment"># Raises TypeError (no implicit conversion of Symbol into String)</span>
</pre>

                              <div class="method-source-code" id="slice-source">
            <pre>static VALUE
env_slice(int argc, VALUE *argv, VALUE _)
{
    int i;
    VALUE key, value, result;

    if (argc == 0) {
        return rb_hash_new();
    }
    result = rb_hash_new_with_size(argc);

    for (i = 0; i &lt; argc; i++) {
        key = argv[i];
        value = rb_f_getenv(Qnil, key);
        if (value != Qnil)
            rb_hash_aset(result, key, value);
    }

    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-store" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ENV[name] = value      &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          store(name, value) &rarr; value
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates, updates, or deletes the named environment variable, returning the value. Both <code>name</code> and <code>value</code> may be instances of <a href="String.html"><code>String</code></a>. See <a href="ENV.html#class-ENV-label-Valid+Names+and+Values">Valid Names and Values</a>.</p>
<ul><li>
<p>If the named environment variable does not exist:</p>
<ul><li>
<p>If <code>value</code> is <code>nil</code>, does nothing.</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">clear</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-keyword">nil</span> <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;bar&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>
</li><li>
<p>If <code>value</code> is not <code>nil</code>, creates the environment variable with <code>name</code> and <code>value</code>:</p>

<pre class="ruby"><span class="ruby-comment"># Create &#39;foo&#39; using ENV.[]=.</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;0&#39;</span> <span class="ruby-comment"># =&gt; &#39;0&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] <span class="ruby-comment"># =&gt; &#39;0&#39;</span>
<span class="ruby-comment"># Create &#39;bar&#39; using ENV.store.</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-string">&#39;1&#39;</span>) <span class="ruby-comment"># =&gt; &#39;1&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;bar&#39;</span>] <span class="ruby-comment"># =&gt; &#39;1&#39;</span>
</pre>
</li></ul>
</li><li>
<p>If the named environment variable exists:</p>
<ul><li>
<p>If <code>value</code> is not <code>nil</code>, updates the environment variable with value <code>value</code>:</p>

<pre class="ruby"><span class="ruby-comment"># Update &#39;foo&#39; using ENV.[]=.</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-string">&#39;2&#39;</span> <span class="ruby-comment"># =&gt; &#39;2&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] <span class="ruby-comment"># =&gt; &#39;2&#39;</span>
<span class="ruby-comment"># Update &#39;bar&#39; using ENV.store.</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-string">&#39;3&#39;</span>) <span class="ruby-comment"># =&gt; &#39;3&#39;</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;bar&#39;</span>] <span class="ruby-comment"># =&gt; &#39;3&#39;</span>
</pre>
</li><li>
<p>If <code>value</code> is <code>nil</code>, deletes the environment variable:</p>

<pre class="ruby"><span class="ruby-comment"># Delete &#39;foo&#39; using ENV.[]=.</span>
<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;foo&#39;</span>] = <span class="ruby-keyword">nil</span> <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-comment"># Delete &#39;bar&#39; using ENV.store.</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">store</span>(<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;bar&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>
</li></ul>
</li></ul>

<p>Raises an exception if <code>name</code> or <code>value</code> is invalid. See <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>.</p>

                              <div class="method-source-code" id="store-source">
            <pre>static VALUE
env_aset_m(VALUE obj, VALUE nm, VALUE val)
{
    return env_aset(nm, val);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-to_a" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_a &rarr; array of 2-element arrays
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the contents of <a href="ENV.html"><code>ENV</code></a> as an <a href="Array.html"><code>Array</code></a> of 2-element Arrays, each of which is a name/value pair:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_a</span> <span class="ruby-comment"># =&gt; [[&quot;bar&quot;, &quot;1&quot;], [&quot;foo&quot;, &quot;0&quot;]]</span>
</pre>

                              <div class="method-source-code" id="to_a-source">
            <pre>static VALUE
env_to_a(VALUE _)
{
    VALUE ary = rb_ary_new();

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);
        while (*env) {
            char *s = strchr(*env, &#39;=&#39;);
            if (s) {
                rb_ary_push(ary, rb_assoc_new(env_str_new(*env, s-*env),
                                              env_str_new2(s+1)));
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-to_h" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_h                        &rarr; hash of name/value pairs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_h {|name, value| block } &rarr; hash of name/value pairs
                              </span>
                            </div>

                            <div class="method-description">
                              <p>With no block, returns a <a href="Hash.html"><code>Hash</code></a> containing all name/value pairs from ENV:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_h</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>With a block, returns a <a href="Hash.html"><code>Hash</code></a> whose items are determined by the block. Each name/value pair in <a href="ENV.html"><code>ENV</code></a> is yielded to the block. The block must return a 2-element <a href="Array.html"><code>Array</code></a> (name/value pair) that is added to the return <a href="Hash.html"><code>Hash</code></a> as a key and value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_h</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_i</span>] } <span class="ruby-comment"># =&gt; {:bar=&gt;1, :foo=&gt;0}</span>
</pre>

<p>Raises an exception if the block does not return an Array:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_h</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span> } <span class="ruby-comment"># Raises TypeError (wrong element type String (expected array))</span>
</pre>

<p>Raises an exception if the block returns an <a href="Array.html"><code>Array</code></a> of the wrong size:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_h</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">name</span>] } <span class="ruby-comment"># Raises ArgumentError (element has wrong array length (expected 2, was 1))</span>
</pre>

                              <div class="method-source-code" id="to_h-source">
            <pre>static VALUE
env_to_h(VALUE _)
{
    VALUE hash = env_to_hash();
    if (rb_block_given_p()) {
        hash = rb_hash_to_h_block(hash);
    }
    return hash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-to_hash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_hash &rarr; hash of name/value pairs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a <a href="Hash.html"><code>Hash</code></a> containing all name/value pairs from ENV:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

                              <div class="method-source-code" id="to_hash-source">
            <pre>static VALUE
env_f_to_hash(VALUE _)
{
    return env_to_hash();
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-to_s" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s &rarr; &quot;ENV&quot;
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <a href="String.html"><code>String</code></a> ‘ENV’:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-comment"># =&gt; &quot;ENV&quot;</span>
</pre>

                              <div class="method-source-code" id="to_s-source">
            <pre>static VALUE
env_to_s(VALUE _)
{
    return rb_usascii_str_new2(&quot;ENV&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-update" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          update                                              &rarr; ENV
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          update(*hashes)                                     &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          update(*hashes) { |name, env_val, hash_val| block } &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          merge!                                              &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          merge!(*hashes)                                     &rarr; ENV
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          merge!(*hashes) { |name, env_val, hash_val| block } &rarr; ENV
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Adds to <a href="ENV.html"><code>ENV</code></a> each key/value pair in the given <code>hash</code>; returns ENV:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>, <span class="ruby-string">&#39;bat&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;3&#39;</span>) <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;bat&quot;=&gt;&quot;3&quot;, &quot;baz&quot;=&gt;&quot;2&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>Deletes the <a href="ENV.html"><code>ENV</code></a> entry for a hash value that is <code>nil</code>:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">nil</span>, <span class="ruby-string">&#39;bat&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;0&quot;}</span>
</pre>

<p>For an already-existing name, if no block given, overwrites the <a href="ENV.html"><code>ENV</code></a> value:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;4&#39;</span>) <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;4&quot;}</span>
</pre>

<p>For an already-existing name, if block given, yields the name, its <a href="ENV.html"><code>ENV</code></a> value, and its hash value; the block’s return value becomes the new name:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;5&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">env_val</span>, <span class="ruby-identifier">hash_val</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">env_val</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">hash_val</span> } <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;45&quot;}</span>
</pre>

<p>Raises an exception if a name or value is invalid (see <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>);</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;6&#39;</span>, <span class="ruby-value">:bar</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;7&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;9&#39;</span>) <span class="ruby-comment"># Raises TypeError (no implicit conversion of Symbol into String)</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;6&quot;}</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;7&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">8</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;9&#39;</span>) <span class="ruby-comment"># Raises TypeError (no implicit conversion of Integer into String)</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;foo&quot;=&gt;&quot;7&quot;}</span>
</pre>

<p>Raises an exception if the block returns an invalid name: (see <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>):</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&#39;bat&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;8&#39;</span>, <span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;9&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">env_val</span>, <span class="ruby-identifier">hash_val</span> <span class="ruby-operator">|</span> <span class="ruby-value">10</span> } <span class="ruby-comment"># Raises TypeError (no implicit conversion of Integer into String)</span>
<span class="ruby-constant">ENV</span> <span class="ruby-comment"># =&gt; {&quot;bar&quot;=&gt;&quot;1&quot;, &quot;bat&quot;=&gt;&quot;8&quot;, &quot;foo&quot;=&gt;&quot;7&quot;}</span>
</pre>

<p>Note that for the exceptions above, hash pairs preceding an invalid name or value are processed normally; those following are ignored.</p>

                              <div class="method-source-code" id="update-source">
            <pre>static VALUE
env_update(int argc, VALUE *argv, VALUE env)
{
    rb_foreach_func *func = rb_block_given_p() ?
        env_update_block_i : env_update_i;
    for (int i = 0; i &lt; argc; ++i) {
        VALUE hash = argv[i];
        if (env == hash) continue;
        hash = to_hash(hash);
        rb_hash_foreach(hash, func, 0);
    }
    return env;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-value-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          value?(value)     &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          has_value?(value) &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>value</code> is the value for some environment variable name, <code>false</code> otherwise:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">value?</span>(<span class="ruby-string">&#39;0&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">has_value?</span>(<span class="ruby-string">&#39;0&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">value?</span>(<span class="ruby-string">&#39;2&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">has_value?</span>(<span class="ruby-string">&#39;2&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="value-3F-source">
            <pre>static VALUE
env_has_value(VALUE dmy, VALUE obj)
{
    obj = rb_check_string_type(obj);
    if (NIL_P(obj)) return Qnil;

    VALUE ret = Qfalse;

    ENV_LOCK();
    {
        char **env = GET_ENVIRON(environ);
        while (*env) {
            char *s = strchr(*env, &#39;=&#39;);
            if (s++) {
                long len = strlen(s);
                if (RSTRING_LEN(obj) == len &amp;&amp; strncmp(s, RSTRING_PTR(obj), len) == 0) {
                    ret = Qtrue;
                    break;
                }
            }
            env++;
        }
        FREE_ENVIRON(environ);
    }
    ENV_UNLOCK();

    return ret;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-values" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          values &rarr; array of values
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns all environment variable values in an Array:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">values</span> <span class="ruby-comment"># =&gt; [&#39;1&#39;, &#39;0&#39;]</span>
</pre>

<p>The order of the values is OS-dependent. See <a href="ENV.html#class-ENV-label-About+Ordering">About Ordering</a>.</p>

<p>Returns the empty <a href="Array.html"><code>Array</code></a> if <a href="ENV.html"><code>ENV</code></a> is empty.</p>

                              <div class="method-source-code" id="values-source">
            <pre>static VALUE
env_f_values(VALUE _)
{
    return env_values();
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-values_at" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          values_at(*names) &rarr; array of values
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an <a href="Array.html"><code>Array</code></a> containing the environment variable values associated with the given names:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-string">&#39;foo&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;0&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-constant">ENV</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-string">&#39;baz&#39;</span>) <span class="ruby-comment"># =&gt; [&quot;0&quot;, &quot;2&quot;]</span>
</pre>

<p>Returns <code>nil</code> in the <a href="Array.html"><code>Array</code></a> for each name that is not an <a href="ENV.html"><code>ENV</code></a> name:</p>

<pre class="ruby"><span class="ruby-constant">ENV</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-string">&#39;bat&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-string">&#39;bam&#39;</span>) <span class="ruby-comment"># =&gt; [&quot;0&quot;, nil, &quot;1&quot;, nil]</span>
</pre>

<p>Returns an empty <a href="Array.html"><code>Array</code></a> if no names given.</p>

<p>Raises an exception if any name is invalid. See <a href="ENV.html#class-ENV-label-Invalid+Names+and+Values">Invalid Names and Values</a>.</p>

                              <div class="method-source-code" id="values_at-source">
            <pre>static VALUE
env_values_at(int argc, VALUE *argv, VALUE _)
{
    VALUE result;
    long i;

    result = rb_ary_new();
    for (i=0; i&lt;argc; i++) {
        rb_ary_push(result, rb_f_getenv(Qnil, argv[i]));
    }
    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

